<?php 
header("content-type:text/html;charset=utf8");
$pdo = new PDO("mysql:host=127.0.0.1;dbname=07c","root","root");
$sql = "select * from xinxi";
$data = $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC);




 ?>
 <!DOCTYPE html>
 <html lang="en">
 <head>
 	<meta charset="UTF-8">
 	<title>Document</title>
 </head>
 <body>
 	<center>
 	<!-- <input type="file" name="daoru" style="display:none" id="daoru1"><button id="daoru2">导入</button> -->
 	<a href="export.php">导入</a>
 	<img src="" class="img" />
 		<table>
 			<tr>
 				<td>课程名</td>
 				<td>课程时间</td>
 				<td>课程数量</td>
 				<td>课程教室</td>
 				<td>操作</td>
 			</tr>
 			<?php foreach ($data as $key => $value): ?>
 				<tr>
	 				<td><?php echo $value['names']; ?></td>
	 				<td><?php echo $value['times']; ?></td>
	 				<td><?php echo $value['num']; ?></td>
	 				<td><?php echo $value['jiaoshi']; ?></td>
	 				<td><button class="del" did="<?php echo $value['id']; ?>">删除</button><button class="update"><a href="update.html?id=<?php echo $value['id']; ?>">修改</a></button></td>
	 			</tr>
 			<?php endforeach ?>
 		</table>
 	</center>
 </body>
 </html>
 <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
 <script>
 $(".del").click(function(){
 	var status = confirm("你确定要删除吗？");
 	if(status == true)
 	{
 		var did = $(this).attr("did");
 		// alert(did);
 		$.ajax({
 			url:"del.php",
 			data:{did:did},
 			dataType:"json",
 			type:"post",
 			success:function(res)
 			{
 				alert(res.msg);
 				location.reload();
 			}
 		})
 	}
 })
 $(".update").click(function(){
 	confirm("你确定要修改吗？");
 	// if(status == true)
 	// {
 	// 	var uid = $(this).attr("uid");
 	// 	// alert(uid);
 	// }
 })
 // confirm('123');
 // 	$("#daoru2").click(function(){
 // 		$("#daoru1").click();
 // 	})
 // 	$("input[type='file']").change(function(){   
	// 	var file = this.files[0];
	// 	if (window.FileReader) {    
	//             var reader = new FileReader();    
	//             reader.readAsDataURL(file);    
	//             //监听文件读取结束后事件    
	//           	reader.onloadend = function (e) {
	//             var img = $(".img").attr("src",e.target.result);    //e.target.result就是最后的路径地址
	// 			// alert();
	//             };    
	// 	} 
	// });



 </script>